package com.lz.library.adapter

import android.view.LayoutInflater
import androidx.recyclerview.widget.DiffUtil.DiffResult

/**
 *  author: you : 2020/4/25
 */
interface IAdapter<T> {

    val data: MutableList<T>

    val layoutInflater: LayoutInflater

    /**
     * 获取绑定的data item
     * @param position
     * @return
     */
    fun getItem(position: Int): T

    fun isEmpty(): Boolean

    fun setNewData(newData: List<T>)

    fun setNewData(newData: List<T>, diffResult: DiffResult)

    /**
     * 添加数据
     * @param addData
     * @param notifyChanged 刷新
     */
    fun addData(addData: List<T>, notifyChanged: Boolean = true)

    /**
     * 移除所有item
     */
    fun removeAll()

    /**
     * 添加单个item
     * @param position
     * @param item
     * @param notifyChanged 刷新
     */
    fun addItem(position: Int = data.size, item: T, notifyChanged: Boolean = true)

    /**
     * 移除单个item
     * @param position
     * @param notifyChanged 刷新
     */
    fun removeItem(position: Int, notifyChanged: Boolean = true)
}